package com.neusoft.elmboot.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

import com.neusoft.elmboot.enums.transStatus;
import com.neusoft.elmboot.po.VirtualWalletTrans;


@Mapper
public interface VirtualWalletTransMapper {

    @Insert("insert into wallet_trans (fromWalletId, amount, toWalletId, createtime, status) values (#{fromWalletId}, #{amount},#{toWalletId}, #{createTime}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "transactionId")
    public Long saveTransaction(VirtualWalletTrans walletTrans);

    @Update("update wallet_trans set status = #{executed} where transactionId = #{transactionId}") 
    public void updateStatus(Long transactionId, transStatus executed);

    @Select("select * from wallet_trans where transactionId= #{transactionId}")
    public VirtualWalletTrans getTransaction(Long transactionId);

    public List<VirtualWalletTrans> listTransactions(Long walletId);

}
